<template>
  <el-form ref="form" label-width="90px" label-position="right">
    <el-descriptions :colon="false" class="pl20" title="" :column="2">
        <el-descriptions-item label="组织名称">{{form.deptName}}</el-descriptions-item>
        <el-descriptions-item label="公司性质">{{selectDictLabel(dict.type.customer_nature, form.deptNature)}}</el-descriptions-item>
        <el-descriptions-item label="组织类型">{{selectDictLabel(dict.type.dept_ent_type, form.deptEntType)}}</el-descriptions-item>
        <el-descriptions-item label="承运货物">{{ onCarryingGoods(form.carryingGoods) }}</el-descriptions-item>
      <el-descriptions-item label="业务范围">{{form.deptBizScope}}</el-descriptions-item>
        <el-descriptions-item label="成立时间">{{form.deptDate}}</el-descriptions-item>
<!--        <el-descriptions-item label="注册资本">{{form.registeredCapital}}</el-descriptions-item>-->
        <el-descriptions-item label="公司规模">{{form.staffNum}}</el-descriptions-item>
        <el-descriptions-item label="拥有车辆">{{form.vehicleNum}}</el-descriptions-item>
        <el-descriptions-item label="办公电话">{{form.deptTel}}</el-descriptions-item>
        <el-descriptions-item label="邮政编码">{{form.deptCode}}</el-descriptions-item>
        <el-descriptions-item label="经营地址">{{form.deptDistrictName}}{{form.deptAddress}}</el-descriptions-item>
        <el-descriptions-item label="联系人">{{form.leader}}</el-descriptions-item>
        <el-descriptions-item label="职务">{{form.deptPost}}</el-descriptions-item>
        <el-descriptions-item label="联系电话">{{form.phone}}</el-descriptions-item>
        <el-descriptions-item label="电子邮箱">{{form.email}}</el-descriptions-item>
    </el-descriptions>
    <el-form-item label="营业执照">
      <imageUpload :isEdit="false" :limit="1" :fileSize="10" v-model="form.deptLicenseUrl" :toImageUrl="form.deptLicenseUrl"/>
    </el-form-item>
    <el-form-item label="开户许可证">
      <imageUpload :isEdit="false" :limit="1" :fileSize="10" v-model="form.deptOpenPremit" :toImageUrl="form.deptOpenPremit"/>
    </el-form-item>
    <el-form-item label="道路经营许可证">
      <imageUpload :isEdit="false" :limit="1" :fileSize="10" v-model="form.deptRoadLicense" :toImageUrl="form.deptRoadLicense"/>
    </el-form-item>
    <el-form-item label="场所照片">
      <imageUpload :isEdit="false" :limit="3" :fileSize="10" v-model="form.deptPlateUrl" :toImageUrl="form.deptPlateUrl"/>
    </el-form-item>
    <el-form-item label="法人身份证正面">
      <imageUpload :isEdit="false" :limit="1" :fileSize="10" v-model="form.legalIdcardUrl" :toImageUrl="form.legalIdcardUrl"/>
    </el-form-item>
    <el-form-item label="法人身份证反面">
      <imageUpload :isEdit="false" :limit="1" :fileSize="10" v-model="form.legalIdcardUrl2" :toImageUrl="form.legalIdcardUrl2"/>
    </el-form-item>
    <el-form-item label="其他材料">
      <fileUpload :isEdit="false" :limit="3" :fileSize="10" :fileType="['png','jpg','jpeg','doc', 'docx', 'pdf']" v-model="form.otherInfo" :toImageUrl="form.otherInfo"/>
    </el-form-item>
    <el-form-item label="备注">
      {{form.remark}}
    </el-form-item>
    <el-form-item label="创建时间">
      {{form.createTime}}
    </el-form-item>
    <div class="common-divider"></div>
    <el-form-item label="手机账号">
      <span class="mr20">{{userInfo.phonenumber}}</span><span>服务商ID：{{userInfo.deptId}}，注册时间：{{userInfo.createTime}}</span>
    </el-form-item>
    <el-form-item label="账号状态">
      <span v-if="form.status === '0'">启用</span>
      <span v-else>禁用</span>
    </el-form-item>
    <div>
      <el-form-item class="inline-block" label="应用系统">
        物流运营管理PC端 完整版
      </el-form-item>
    </div>
<!--    <el-form-item label="生效时长">-->
<!--    </el-form-item>-->
  </el-form>
</template>

<script>
export default {
  name: "basicDetail",
  dicts: ['customer_nature', 'dept_ent_type','goods_type'],
  components: {
  },
  props: {
    userInfo: {
      type: Object,
      default: () => {}
    },
  },
  data() {
    return {
      form: this.userInfo.dept
    };
  },
  watch: {
    userInfo: {
      handler(val) {
        this.form=val.dept
        //this.form.carryingGoods = a.dept.carryingGoods ? a.dept.carryingGoods.split(',') : []
        this.form.deptDistrict=String(val.dept.deptDistrict)
      },
      deep:true,
      immediate:true
    },
  },
  computed:{
    onCarryingGoods() {
      return function(data) {
        if(data)
        {
          const list = data.split(',')
          return list.map(item => {
            return this.selectDictLabel(this.dict.type.goods_type, item)
          }).join(',')
        }
        else return ''
      }
    }
  },
  methods: {
    // onCarryingGoods(data) {
    //   const list = data.split(',')
    //   return list.map(item => {
    //     return this.selectDictLabel(this.dict.type.goods_type, item)
    //   }).join(',')
    // },
    handleValidate() {
      return new Promise((resolve) => {
        this.$refs.form.validate(valid => {
          if (valid) {
            resolve(true)
          } else {
            resolve(false)
          }
        });
      })
    },
    limitInput(value,name) {
      this.form[name] = ('' + value) // 第一步：转成字符串
            .replace(/[^\d]/g, "") // 只能输入数字
            .replace(/^0+(\d)/, "$1"); // 第一位0开头，0后面为数字，则过滤掉，取后面的数字
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
</style>
